home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 April / PCWorld_2007-04_cd.bin / multimedia / mypic3d / mypicsalbumins.exe / {app} / Inno Setup 5 / Builtins.iss next >
Text File  |  2005-04-09  |  11KB  |  355 lines

  1. ; BEGIN BUILTINS.ISS
  2. //
  3. // Inno Setup Preprocessor 5.0
  4. //
  5. // Copyright (C) 2001-2002 Alex Yackimoff. All Rights Reserved.
  6. // http://ispp.sourceforge.net
  7. //
  8. // Inno Setup (C) 1997-2005 Jordan Russell. All Rights Reserved.
  9. // Portions by Martijn Laan.
  10. //
  11. // $Id: Builtins.iss,v 1.7 2005/04/09 11:39:42 mlaan Exp $
  12. //
  13. #if defined(ISPP_INVOKED) && !defined(_BUILTINS_ISS_)
  14. //
  15. #if PREPROCVER < 0x01000000
  16. # error Inno Setup Preprocessor version is outdated
  17. #endif
  18. //
  19. #define _BUILTINS_ISS_
  20. //
  21. // ===========================================================================
  22. //
  23. // Default states for options.
  24. //
  25. //#pragma parseroption -b+ ; short circuit boolean evaluation: on
  26. //#pragma parseroption -m- ; short circuit multiplication evaluation (0 * A will not eval A): off
  27. //#pragma parseroption -p+ ; string literals without escape sequences: on
  28. //#pragma parseroption -u- ; allow undeclared identifiers: off
  29. //#pragma option -c+       ; pass script to the compiler: on
  30. //#pragma option -e-       ; emit empty lines to translation: off
  31. //#pragma option -v-       ; verbose mode: off
  32. //
  33. // ---------------------------------------------------------------------------
  34. //
  35. // Verbose levels:
  36. // 0 - #include and #file acknowledgements
  37. // 1 - information about any temp files created by #file
  38. // 2 - #insert and #append acknowledgements
  39. // 3 - reserved
  40. // 4 - #dim, #define and #undef acknowledgements
  41. // 5 - reserved
  42. // 6 - conditional inclusion acknowledgements
  43. // 7 - reserved
  44. // 8 - show strings emitted with #emit directive
  45. // 9 - macro and functions successfull call acknowledgements
  46. //10 - Local macro array allocation acknowledgements
  47. //
  48. //#pragma verboselevel 0
  49. //
  50. #ifndef __POPT_P__
  51. # define private CStrings
  52. # pragma parseroption -p+
  53. #endif
  54. //
  55. #pragma spansymbol "\"
  56. //
  57. #define True               1
  58. #define False              0
  59. #define Yes                True
  60. #define No                                 False
  61. //
  62. #define MaxInt             0x7FFFFFFFL
  63. #define MinInt             0x80000000L
  64. //
  65. #define NULL
  66. #define void
  67. //
  68. // TypeOf constants
  69. //
  70. #define TYPE_ERROR         0
  71. #define TYPE_NULL          1
  72. #define TYPE_INTEGER       2
  73. #define TYPE_STRING        3
  74. #define TYPE_MACRO         4
  75. #define TYPE_FUNC          5
  76. #define TYPE_ARRAY         6
  77. //
  78. // Helper macro to find out the type of an array element or expression. TypeOf
  79. // standard function only allows identifier as its parameter. Use this macro
  80. // to convert an expression to identifier.
  81. //
  82. #define TypeOf2(any Expr) TypeOf(Expr)
  83. //
  84. // ReadReg constants
  85. //
  86. #define HKEY_CLASSES_ROOT  0x80000000UL
  87. #define HKEY_CURRENT_USER  0x80000001UL
  88. #define HKEY_LOCAL_MACHINE 0x80000002UL
  89. #define HKEY_USERS         0x80000003UL
  90. //
  91. #define HKCR               HKEY_CLASSES_ROOT
  92. #define HKCU               HKEY_CURRENT_USER
  93. #define HKLM               HKEY_LOCAL_MACHINE
  94. #define HKU                HKEY_USERS
  95. //
  96. // Exec constants
  97. //
  98. #define SW_HIDE            0
  99. #define SW_SHOWNORMAL      1
  100. #define SW_NORMAL          1
  101. #define SW_SHOWMINIMIZED   2
  102. #define SW_SHOWMAXIMIZED   3
  103. #define SW_MAXIMIZE        3
  104. #define SW_SHOWNOACTIVATE  4
  105. #define SW_SHOW            5
  106. #define SW_MINIMIZE        6
  107. #define SW_SHOWMINNOACTIVE 7
  108. #define SW_SHOWNA          8
  109. #define SW_RESTORE         9
  110. #define SW_SHOWDEFAULT     10
  111. #define SW_MAX             10
  112. //
  113. // Find constants
  114. //
  115. #define FIND_MATCH         0x00
  116. #define FIND_BEGINS        0x01
  117. #define FIND_ENDS          0x02
  118. #define FIND_CONTAINS      0x03
  119. #define FIND_CASESENSITIVE 0x04 
  120. #define FIND_SENSITIVE     FIND_CASESENSITIVE
  121. #define FIND_AND           0x00
  122. #define FIND_OR            0x08
  123. #define FIND_NOT           0x10
  124. #define FIND_TRIM          0x20
  125. //
  126. // FindFirst constants
  127. //
  128. #define faReadOnly         0x00000001
  129. #define faHidden           0x00000002
  130. #define faSysFile          0x00000004
  131. #define faVolumeID         0x00000008
  132. #define faDirectory        0x00000010
  133. #define faArchive          0x00000020
  134. #define faSymLink          0x00000040
  135. #define faAnyFile          0x0000003F
  136. //
  137. // GetStringFileInfo standard names
  138. //
  139. #define COMPANY_NAME       "CompanyName"
  140. #define FILE_DESCRIPTION   "FileDescription"
  141. #define FILE_VERSION       "FileVersion"
  142. #define INTERNAL_NAME      "InternalName"
  143. #define LEGAL_COPYRIGHT    "LegalCopyright"
  144. #define ORIGINAL_FILENAME  "OriginalFilename"
  145. #define PRODUCT_NAME       "ProductName"
  146. #define PRODUCT_VERSION    "ProductVersion"
  147. //
  148. // GetStringFileInfo helpers
  149. //
  150. #define GetFileCompany(str FileName) GetStringFileInfo(FileName, COMPANY_NAME)
  151. #define GetFileCopyright(str FileName) GetStringFileInfo(FileName, LEGAL_COPYRIGHT)
  152. #define GetFileDescription(str FileName) GetStringFileInfo(FileName, FILE_DESCRIPTION)
  153. #define GetFileProductVersion(str FileName) GetStringFileInfo(FileName, PRODUCT_VERSION)
  154. #define GetFileVersionString(str FileName) GetStringFileInfo(FileName, FILE_VERSION)
  155. //
  156. // ParseVersion
  157. //
  158. // Macro internally calls GetFileVersion function and parses string returned
  159. // by that function (in form "0.0.0.0"). All four version elements are stored
  160. // in by-reference parameters Major, Minor, Rev, and Build. Macro returns
  161. // string returned by GetFileVersion.
  162. //
  163. #define DeleteToFirstPeriod(str *S) \
  164.   Local[1] = Copy(S, 1, (Local[0] = Pos(".", S)) - 1), \
  165.   S = Copy(S, Local[0] + 1), \
  166.   Local[1]
  167. //
  168. #define ParseVersion(str FileName, *Major, *Minor, *Rev, *Build) \
  169.   Local[1]  = Local[0] = GetFileVersion(FileName), \
  170.   Local[1] == "" ? "" : ( \
  171.     Major   = Int(DeleteToFirstPeriod(Local[1])), \
  172.     Minor   = Int(DeleteToFirstPeriod(Local[1])), \
  173.     Rev     = Int(DeleteToFirstPeriod(Local[1])), \
  174.     Build   = Int(Local[1]), \
  175.   Local[0])
  176. //
  177. // EncodeVer
  178. //
  179. // Encodes given four version elements to a 32 bit integer number (8 bits for
  180. // each element, i.e. elements must be within 0...255 range).
  181. //
  182. #define EncodeVer(int Major, int Minor, int Revision = 0, int Build = -1) \
  183.   Major << 24 | (Minor & 0xFF) << 16 | (Revision & 0xFF) << 8 | (Build >= 0 ? Build & 0xFF : 0)
  184. //
  185. // DecodeVer
  186. //
  187. // Decodes given 32 bit integer encoded version to its string representation,
  188. // Digits parameter indicates how many elements to show (if the fourth element
  189. // is 0, it won't be shown anyway).
  190. //
  191. #define DecodeVer(int Ver, int Digits = 3) \
  192.   Str(Ver >> 0x18 & 0xFF) + (Digits > 1 ? "." : "") + \
  193.   (Digits > 1 ? \
  194.     Str(Ver >> 0x10 & 0xFF) + (Digits > 2 ? "." : "") : "") + \
  195.   (Digits > 2 ? \
  196.     Str(Ver >> 0x08 & 0xFF) + (Digits > 3 && (Local = Ver & 0xFF) ? "." : "") : "") + \
  197.   (Digits > 3 && Local ? \
  198.     Str(Ver & 0xFF) : "")
  199. //
  200. // FindSection
  201. //
  202. // Returns index of the line following the header of the section. This macro
  203. // is intended to be used with #insert directive.
  204. //
  205. #define FindSection(str Section = "Files") \
  206.   Find(0, "[" + Section + "]", FIND_MATCH | FIND_TRIM) + 1
  207. //
  208. // FindSectionEnd
  209. //
  210. // Returns index of the line following last entry of the section. This macro
  211. // is intended to be used with #insert directive.
  212. //
  213. #if VER >= 0x03000000
  214. # define FindNextSection(int Line) \
  215.     Find(Line, "[", FIND_BEGINS | FIND_TRIM, "]", FIND_ENDS | FIND_AND)
  216. # define FindSectionEnd(str Section = "Files") \
  217.     FindNextSection(FindSection(Section))
  218. #else
  219. # define FindSectionEnd(str Section = "Files") \
  220.     FindSection(Section) + EntryCount(Section)
  221. #endif
  222. //
  223. // FindCode
  224. //
  225. // Returns index of the line (of translation) following either [Code] section
  226. // header, or "program" keyword, if any.
  227. //
  228. #ifdef ISX
  229. //
  230. # define FindCode() \
  231.     Local[1] = FindSection("Code"), \
  232.     Local[0] = Find(Local[1] - 1, "program", FIND_BEGINS, ";", FIND_ENDS | FIND_AND), \
  233.     (Local[0] < 0 ? Local[1] : Local[0] + 1)
  234. //
  235. #endif
  236. //
  237. // ExtractFilePath
  238. //
  239. // Returns directory portion of the given filename without backslash (unless
  240. // it is a root directory). If PathName doesn't contain directory portion,
  241. // the result is an empty string.
  242. //
  243. #define ExtractFilePath(str PathName) \
  244.   (Local[0] = \
  245.     !(Local[1] = RPos("\", PathName)) ? \
  246.       "" : \
  247.       Copy(PathName, 1, Local[1] - 1)), \
  248.   Local[0] + \
  249.     ((Local[2] = Len(Local[0])) == 2 && Copy(Local[0], Local[2]) == ":" ? \
  250.       "\" : \
  251.       "")
  252. #define ExtractFileDir(str PathName) \
  253.   RemoveBackslash(ExtractFilePath(PathName))
  254.  
  255. #define ExtractFileExt(str PathName) \
  256.   Local[0] = RPos(".", PathName), \
  257.   Copy(PathName, Local[0] + 1)
  258. //
  259. // ExtractFileName
  260. //
  261. // Returns name portion of the given filename. If PathName ends with
  262. // a backslash, the result is an empty string.
  263. //
  264. #define ExtractFileName(str PathName) \
  265.   !(Local[0] = RPos("\", PathName)) ? \
  266.     PathName : \
  267.     Copy(PathName, Local[0] + 1)
  268. //
  269. // ChangeFileExt
  270. //
  271. // Changes extension in FileName with NewExt. NewExt must not contain
  272. // period.
  273. //
  274. #define ChangeFileExt(str FileName, str NewExt) \
  275.   !(Local[0] = RPos(".", FileName)) ? \
  276.     FileName + "." + NewExt : \
  277.     Copy(FileName, 1, Local[0]) + NewExt
  278. //
  279. // AddBackslash
  280. //
  281. // Adds a backslash to the string, if it's not already there.
  282. //
  283. #define AddBackslash(str S) \
  284.   Copy(S, Len(S)) == "\" ? S : S + "\"
  285. //
  286. // RemoveBackslash
  287. //
  288. // Removes trailing backslash from the string unless the string points to
  289. // a root directory.
  290. //
  291. #define RemoveBackslash(str S) \
  292.   Local[0] = Len(S), \
  293.   Local[0] > 0 ? \
  294.     Copy(S, Local[0]) == "\" ? \
  295.       (Local[0] == 3 && Copy(S, 2, 1) == ":" ? \
  296.         S : \
  297.         Copy(S, 1, Local[0] - 1)) : \
  298.       S : \
  299.     ""
  300. //
  301. // Delete
  302. //
  303. // Deletes specified number of characters beginning with Index from S. S is
  304. // passed by reference (therefore is modified). Acts like Delete function in
  305. // Delphi (from System unit).
  306. //
  307. #define Delete(str *S, int Index, int Count = MaxInt) \
  308.   S = Copy(S, 1, Index - 1) + Copy(S, Index + Count)
  309. //
  310. // Insert
  311. //
  312. // Inserts specified Substr at Index'th character into S. S is passed by
  313. // reference (therefore is modified).
  314. //
  315. #define Insert(str *S, int Index, str Substr) \
  316.   Index > Len(S) + 1 ? \
  317.     S : \
  318.     S = Copy(S, 1, Index - 1) + SubStr + Copy(S, Index)
  319. //
  320. // YesNo, IsDirSet
  321. //
  322. // Returns nonzero value if given string is "yes", "true" or "1". Intended to
  323. // be used with SetupSetting function. This macro replaces YesNo function
  324. // available in previous releases.
  325. //
  326. #define YesNo(str S) \
  327.   (S = LowerCase(S)) == "yes" || S == "true" || S == "1"
  328. //
  329. #define IsDirSet(str SetupDirective) \
  330.   YesNo(SetupSetting(SetupDirective))
  331. //
  332. //
  333. #define Power(int X, int P = 2) \
  334.   !P ? 1 : X * Power(X, P - 1)
  335. //
  336. #define Min(int A, int B, int C = MaxInt)  \
  337.   A < B ? A < C ? Int(A) : Int(C) : Int(B)
  338. //
  339. #define Max(int A, int B, int C = MinInt)  \
  340.   A > B ? A > C ? Int(A) : Int(C) : Int(B)
  341. //
  342.  
  343. ; The following message can be overriden in ISS script.
  344. ; It is not required by ISPP license agreement, but it would be appreciated
  345. ; if you do not remove this note.
  346.  
  347. [Messages]
  348. AboutSetupNote=Inno Setup Preprocessor home page:%nhttp://ispp.sourceforge.net/
  349. [/Messages]
  350. #ifdef CStrings
  351. # pragma parseroption -p-
  352. #endif
  353. #endif
  354. ; END BUILTINS.ISS
  355.